<?php
/**
* @version $Id: admin.support.html.php 10002 2008-02-08 10:56:57Z willebil $
* @package Joomla
* @subpackage support
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

/**
* @package Joomla
* @subpackage support
*/
class HTML_support {

	function showsupports( &$rows, &$pageNav, $search, $option, &$lists ) {
		global $my, $database;

		mosCommonHTML::loadOverlib();
		?>
		<form action="index2.php" method="post" name="adminForm">
		<table class="adminheading">
		<tr>
			<th>
			Quản trị hỗ trợ trực tuyến
			</th>
			<td>
			Tìm:
			</td>
			<td>
			<input type="text" name="search" value="<?php echo htmlspecialchars( $search );?>" class="inputbox" onChange="document.adminForm.submit();" />
			</td>			
		</tr>
		</table>

		<table class="adminlist">
		<tr>
			<th width="20">
			#
			</th>
			<th width="20" class="title">
			<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" />
			</th>
			<th class="title">
			Tiêu đề
			</th>
			<th class="title">
			Điện thoại
			</th>
			<th class="title">
			Yahoo
			</th>
			<th class="title">
			Skype
			</th>															
		</tr>
		<?php
		$k = 0;
		for ($i=0, $n=count($rows); $i < $n; $i++) {
			$row = $rows[$i];
			mosMakeHtmlSafe($row);
			$link 	= 'index2.php?option=com_support&task=editA&hidemainmenu=1&id='. $row->id;

			$img 	= $row->published ? 'tick.png' : 'publish_x.png';
			$task 	= $row->published ? 'unpublish' : 'publish';
			$alt 	= $row->published ? 'published' : 'Unpublished';

			$checked 	= mosCommonHTML::CheckedOutProcessing( $row, $i );
			?>
			<tr class="<?php echo "row$k"; ?>">
				<td>
				<?php echo $pageNav->rowNumber( $i ); ?>
				</td>
				<td>
				<?php echo $checked; ?>
				</td>
				<td>
				<?php
				if ( $row->checked_out && ( $row->checked_out != $my->id ) ) {
					echo $row->name;
				} else {
					?>
					<a href="<?php echo $link; ?>" title="Edit support">
					<?php echo $row->name; ?>
					</a>
					<?php
				}
				?>
				</td>
				<td><?php echo $row->phone; ?></td>
				<td><?php echo $row->yahoo; ?></td>
				<td><?php echo $row->skype; ?></td>											
			</tr>
			<?php
			$k = 1 - $k;
		}
		?>
		</table>
		<?php echo $pageNav->getListFooter(); ?>

		<input type="hidden" name="option" value="<?php echo $option; ?>" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="hidemainmenu" value="0">
		<input type="hidden" name="<?php echo josSpoofValue(); ?>" value="1" />
		</form>
		<?php
	}


	function editsupport( &$row, &$lists, $option, &$params ) {
		global $mosConfig_live_site, $database;
		$uploaddir = $mosConfig_live_site."/administrator/components/com_support/uploads/";

		if ($row->image == '') {
			$row->image = 'blank.png';
		}

		$tabs = new mosTabs(0);

		mosMakeHtmlSafe( $row, ENT_QUOTES, 'misc' );
		$rowid = intval($row->id);
		?>
		<script language="javascript" type="text/javascript">
		<!--
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}
			// do field validation
			else if ( form.name.value == 0 ) {
				alert( "Vui lòng nhập tên khách hàng !" );
				form.name.focus();
			} else {
				submitform( pressbutton );
			}
		}
		//-->
		</script>

		<form action="index2.php" enctype="multipart/form-data" method="post" name="adminForm">
		<table class="adminheading">
		<tr>
			<th>
			Quản trị hỗ trợ trực tuyến:
			<small>
			<?php echo $row->id ? 'Edit' : 'New';?>
			</small>
			</th>
		</tr>
		</table>

		<table width="100%">
		<tr>
			<td width="70%" valign="top">
				<table width="100%" class="adminform">				
				<tr>
					<td width="20%" align="right">
					Tên người hỗ trợ :
					</td>
					<td >
					<input class="inputbox" type="text" name="name" size="50" maxlength="100" value="<?php echo $row->name; ?>" />
					</td>
				</tr>
				<tr>
					<td width="20%" align="right">
					Số điện thoại :
					</td>
					<td >
					<input class="inputbox" type="text" name="phone" size="50" maxlength="100" value="<?php echo $row->phone; ?>" />
					</td>
				</tr>
				<tr>
					<td width="20%" align="right">
					Nick yahoo:
					</td>
					<td >
					<input class="inputbox" type="text" name="yahoo" size="50" maxlength="100" value="<?php echo $row->yahoo; ?>" />
					</td>
				</tr>
				<tr>
					<td width="20%" align="right">
					Skype :
					</td>
					<td >
					<input class="inputbox" type="text" name="skype" size="50" maxlength="100" value="<?php echo $row->skype; ?>" />
					</td>
				</tr>				
				</table>
			</td>			
		</tr>
		</table>

		<script language="Javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script>
		<input type="hidden" name="option" value="<?php echo $option; ?>" />
		<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="<?php echo josSpoofValue(); ?>" value="1" />
		</form>
		<?php
	}
}
?>
